package com.springDemo.Mybatis.service;

import com.springDemo.Mybatis.dao.IAddressBookDao;
import com.springDemo.Mybatis.entity.AddressBook;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2016/8/11.
 */
public class AddressBookServiceImpl implements IAddressBookService {

    @Resource
    public IAddressBookDao addressBookDaoMyBatis;

    @Override
    public void addAddressBook(AddressBook addressBook) {
        addressBookDaoMyBatis.save(addressBook);
    }

    @Test
    public void test(){
        String[] resources = new String[]{"spring-config.xml","spring-jdbc-config.xml"};
        ApplicationContext ac = new ClassPathXmlApplicationContext(resources);
        IAddressBookService addressBookService = ac.getBean("addressBookService",IAddressBookService.class);
        AddressBook ab = new AddressBook();
        ab.setName("V xxxxV amplifier grievances");
        ab.setAddress("成都市成都成都成");
        ab.setSex("女");
        ab.setTel("454545454");
        addressBookService.addAddressBook(ab);
    }
}
